import Vue from 'vue'
import VueRouter from 'vue-router'
import Laucher from '@/views/Laucher.vue'

Vue.use(VueRouter)
//全局路由配置， 重复路由不报错
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to){
    return VueRouterPush.call(this,to).catch(err => err)
}
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(to){
    return VueRouterReplace.call(this,to).catch(err => err)
}
const routes = [
  {
    //引导页面
    path: '/',
    name: 'Laucher',
    component: Laucher
  },
  {
    path: '/Main',
    name: 'Main',
    component: () => import('@/views/Main.vue'),
    redirect: '/Main/CommodityList',
    children: [
      {
        // 商品管理-商品列表
        path: '/Main/CommodityList',
        name: 'CommodityList',
        component: () => import('@/views/commodity/commodityList.vue'),
      },
      {
        // 商品管理-添加商品
        path: '/Main/AddCompodity',
        name: 'AddCompodity',
        component: () => import('@/views/commodity/components/AddCommodityAll.vue'),
      },
      {
        // 库存管理-商品入库
        path: '/Main/CommodityStockroom',
        name: 'CommodityStockroom',
        component: () => import('@/views/lnventory/commodityStockroom.vue')
      },
      {
        // 库存管理-库存盘点
        path: '/Main/StockCount',
        name: 'StockCount',
        component: () => import('@/views/lnventory/stockCount.vue')
      },
      {
        // 营销管理-商品定价
        path: '/Main/CommodityPricing',
        name: 'CommodityPricing',
        component: () => import('@/views/marketing/commodityPricing.vue')
      },
      {
        // 营销管理-商品上下架
        path: '/Main/ProductListRemove',
        name: 'ProductListRemove',
        component: () => import('@/views/marketing/productListRemove.vue')
      },
      {
        // 营销管理-秒杀活动
        path: '/Main/FlashActivity',
        name: 'FlashActivity',
        component: () => import('@/views/marketing/flashActivity.vue')
      },
      {
        // 营销管理-商品推荐
        path: '/Main/RecommendedGoods',
        name: 'recommendedGoods',
        component: () => import('@/views/marketing/recommendedGoods.vue')
      },
      {
        // 订单管理-待发货（列表）
        path: '/Main/ToBeShippedOrder',
        name: 'ToBeShippedOrder',
        component: () => import('@/views/order/toBeShippedOrder.vue')
      },
      // 订单管理-待发货订单详情
      {
        path: '/Main/ToBeShippedOrderDetail',
        name: 'ToBeShippedOrderDetail',
        component: () => import('@/views/order/components/ToBeShippedOrderDetail.vue')
      },
      // 订单管理-已发货订单详情
      {
        path: '/Main/ShippedOrderDetail',
        name: 'ShippedOrderDetail',
        component: () => import('@/views/order/components/ShippedOrderDetail.vue')
      },
      
      // 订单管理-所有订单
      {
        path: '/Main/AllOrders',
        name: 'AllOrders',
        component: () => import('@/views/order/allOrders.vue')
      },
      // 订单管理-物流详情
      {
        path: '/Main/LogisticsDetail',
        name: 'LogisticsDetail',
        component: () => import('@/views/order/components/LogisticsDetails.vue')
      },

      // 订单管理-退换货订单
      {
        path: '/Main/ReturnOExchangeOrder',
        name: 'ReturnOExchangeOrder',
        component: () => import('@/views/order/returnOExchangeOrder.vue')
      },
      // 订单管理-已发货订单
      {
        path: '/Main/ShippedOrder',
        name: 'ShippedOrder',
        component: () => import('@/views/order/shippedOrder.vue')

      },
      // 订单管理-已完成订单
      {
        path: '/Main/CompletedOrder',
        name: 'CompletedOrder',
        component: () => import('@/views/order/completedOrder.vue')
      },
      // 订单管理-已完成订单详情
      {
        path: '/Main/CompletedOrderDetail',
        name: 'CompletedOrderDetail',
        component: () => import('@/views/order/components/CompletedOrderDetail.vue')
      },
      // 订单管理-退换货订单详情
      {
        path: '/Main/ReturnOExchangeOrderDetail',
        name: 'ReturnOExchangeOrderDetail',
        component: () => import('@/views/order/components/ReturnOExchangeOrderDetail.vue')
      },
      // 咨询及评价-商品咨询
      {
        path: '/Main/ConusltManager',
        name: 'ConusltManager',
        component: () => import('@/views/conuslt/commodityInquiry.vue')
      },
    ]
  }

]

const router = new VueRouter({
  routes,
  // base: '/web/shopping-mail'
})

export default router
